package com.ruoyi.web.controller.resLipstick;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.ResLipstick.domain.ResLipstick;
import com.ruoyi.ResLipstick.service.ResLipstickService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.TimeUnit;

@RestController
@Api(tags = "口红管理")
@Anonymous
public class resLipstickController {
    @Autowired
     ResLipstickService service;

//董虹妤2619
    @ApiOperation(value = "获取所有口红列表")
    @PostMapping("/GetLipstickList")
    public AjaxResult GetLipstickList(@RequestBody ResLipstick l){
        return AjaxResult.success(service.getLipstickList(l));
    }
 // 根据id获取口红详情信息 董虹妤2619
    @ApiOperation(value = "获取口红详情信息",notes = "TODO,取得某个口红的详情信息")
    @ApiImplicitParam(name = "id",value = "口红ID",
            required = true,dataType = "long",paramType = "path",
            dataTypeClass = Long.class)
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id){
        return  AjaxResult.success(service.selectResLipstickById(id));
    }
    //新增口红  董虹妤2619
    @ApiOperation(value = "新增口红")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ResLipstick resLipstick){
        return AjaxResult.success(service.insertResLipstick(resLipstick));
    }
    //修改口红  董虹妤2619
    @ApiOperation(value = "修改口红")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody ResLipstick resLipstick){
        return AjaxResult.success(service.updateResLipstick(resLipstick));
    }
    //删除口红 董虹妤2619
    @ApiOperation(value = "删除口红")
    @ApiImplicitParam(name = "id",value = "口红ID",required = true,
            dataType = "long",paramType = "path",dataTypeClass = Long.class)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable int id){
        return AjaxResult.success(service.deleteResLipstick(id));
    }

}
